/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __COLLIDER_COMPONENT__
#define __COLLIDER_COMPONENT__

#include "Component.h"

namespace PQEngine
{
	enum ColliderType
	{
		COLLIDER_PLANE,
		COLLIDER_BOX,
		COLLIDER_SPHERE,

		//Add collider count just above this line!
		COLLIDER_COUNT,
	};

	/*Base class of all collider component
	*/
	class ColliderComponent 
		: public Component
	{
	public:
		ColliderComponent(ColliderType type);

		inline ColliderType getColliderType()
		{
			return _colliderType;
		}

	private:
		ColliderType _colliderType;
	};

	/*
	*/
	class PlaneColliderComponent
		: public ColliderComponent
	{
	
	public:
		PlaneColliderComponent()
			: ColliderComponent(COLLIDER_PLANE),_normal(Ogre::Vector3(0,1,0)),_distance(0)
		{
			_objectType=OBJECT_TYPE_COMPONENT_PLANE_COLLIDER;
		}

		PlaneColliderComponent(float x,float y,float z,float d)
			: ColliderComponent(COLLIDER_PLANE),_normal(Ogre::Vector3(x,y,z)),_distance(d)
		{
		}

		inline Ogre::Vector3 getNormal()
		{
			return _normal;
		}

		inline void setNormal(Ogre::Vector3 normal)	
		{
			_normal=normal;
		}

		inline float getDistance()
		{
			return _distance;
		}

		inline void setDistance(float distance)
		{
			_distance=distance;
		}
	private:
		Ogre::Vector3 _normal;
		float _distance;
	};

	class SphereColliderComponent
		: public ColliderComponent
	{
	public:
		SphereColliderComponent()
			: ColliderComponent(COLLIDER_SPHERE),_position(Ogre::Vector3(0,0,0)),_radius(1)
		{
			_objectType=OBJECT_TYPE_COMPONENT_SPHERE_COLLIDER;
		}

		SphereColliderComponent(float x,float y,float z,float r)
			: ColliderComponent(COLLIDER_SPHERE),_position(Ogre::Vector3(x,y,z)),_radius(r)
		{
		}


		inline void setRadius(float radius)
		{
			_radius=radius;
		}

		inline float getRadius()
		{
			return _radius;
		}

		inline Ogre::Vector3& getPosition()
		{
			return _position;
		}

		inline void setPosition(Ogre::Vector3 position)
		{
			_position=position;
		}
	private:
		Ogre::Vector3 _position;
		float _radius;
	};

	class BoxColliderComponent
		: public ColliderComponent
	{
	public:
		BoxColliderComponent::BoxColliderComponent()
			: ColliderComponent(COLLIDER_BOX),_position(Ogre::Vector3(0,0,0)),_size(Ogre::Vector3(1,1,1))
		{
			_objectType=OBJECT_TYPE_COMPONENT_BOX_COLLIDER;
		}

		BoxColliderComponent::BoxColliderComponent(float x,float y,float z,float w,float h,float l)//width,height,length
			: ColliderComponent(COLLIDER_BOX),_position(Ogre::Vector3(x,y,z)),_size(Ogre::Vector3(w,h,l))
		{
		}

		inline Ogre::Vector3 getPosition()
		{
			return _position;
		}

		inline void setPosition(Ogre::Vector3 position)
		{
			_position=position;
		}

		inline Ogre::Vector3 getSize()
		{
			return _size;
		}

		inline void setSize(Ogre::Vector3 size)
		{
			_size=size;
		}
	private:
		Ogre::Vector3 _position;//center pos
		Ogre::Vector3 _size;
	};

}
#endif
